package com.xiaomaoguai.jaeger.trace.service.impl;

import com.xiaomaoguai.jaeger.trace.service.KeplerJaegerSwitch;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * 开普勒Jaeger开关Impl
 *
 * @author August.Zhang
 * @version v1.0.0
 * @date 2020/2/3 14:24
 * @since JDK 1.8
 */
public class KeplerJaegerSwitchImpl implements KeplerJaegerSwitch {

	/**
	 * 开关值
	 */
	private AtomicBoolean switchValue = new AtomicBoolean(true);


	/**
	 * 得到开关值
	 *
	 * @return boolean
	 */
	@Override
	public boolean getSwitchValue() {
		return switchValue.get();
	}

	/**
	 * 旋转开关
	 *
	 * @param switchValue 开关值
	 * @return boolean
	 */
	@Override
	public boolean turnSwitch(final boolean switchValue) {
		return this.switchValue.compareAndSet(!switchValue, switchValue);
	}

}
